package com.yangfan.screenshot.utils;

import android.content.Context;
import android.os.Environment;

import androidx.annotation.NonNull;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author : yangfan
 * @date : 2022/12/9-16:50
 * desc   :
 */
public final class FileUtil {
    public static final FileUtil instance = new FileUtil();

    private static final String path = File.separator + "Screenshots" + File.separator;

    private static final String prefix = "Screenshot";

    private static final String f12255d = "Long_Screenshot";

    private FileUtil() {
    }

    public final String getSavePath(Context context) {
        return context.getCacheDir() + path;
    }

    public final void mkdirs(@NonNull String str) {
        File file = new File(str);
        if (file.exists()) {
            return;
        }
        file.mkdirs();
    }

    public final String getFileName() {
        String format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(prefix);
        stringBuffer.append("_");
        stringBuffer.append(format);
        stringBuffer.append(".jpg");
        String stringBuffer2 = stringBuffer.toString();
        return stringBuffer2;
    }
}
